<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!doctype html>
<html lang="zh-CN">
<body>
	<h2>Topic Message</h2>

	<input placeholder="Topic Name" id="topicName" style="width: 300px;" />
	<br />
	<textarea style="width: 500px; height: 100px;" id="topicMessage"
		placeholder="消息内容"></textarea>
	<div>
		<button id="btnSendTopic">发送</button>
	</div>

	<h2>Queue Message</h2>

	<input placeholder="Queue Name" id="queueName" style="width: 300px;" />
	<br />
	<textarea style="width: 500px; height: 100px;" id="QueueMessage"
		placeholder="消息内容"></textarea>
	<div>
		<button id="btnSendQueue">发送</button>
	</div>
	<script src="../static/jquery-1.11.0.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#btnSendTopic").click(function() {

				var p = {
					t : new Date(),
					name : $("#topicName").val().trim(),
					msg : $("#topicMessage").val().trim(),
					type : "topic"
				};

				$.post("sendJms.htm", p, function(data) {
					if (data.code == "SUCCESS") {
						$("#topicName").val("");
						$("#topicMessage").val("");
						return;
					}
					alert(JSON.stringify(data));
				}, "json");
			});

			$("#btnSendQueue").click(function() {

				var p = {
					t : new Date(),
					name : $("#queueName").val().trim(),
					msg : $("#QueueMessage").val().trim(),
					type : "queue"
				};

				$.post("sendJms.htm", p, function(data) {
					if (data.code == "SUCCESS") {
						$("#queueName").val("");
						$("#QueueMessage").val("");
						return;
					}
					alert(JSON.stringify(data));
				}, "json");
			});
		});
	</script>
</body>
</html>
